﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using nyxwin.Main.Base.ViewModels;
using nyxwin.Data.Discussions;
using nyxwin.Data.Links;
using nyxwin.Common.Silverlight.Commands;
using nyxwin.Common.Providers;

namespace nyxwin.Main.ViewModel.SubModels
{
    public class DiscussionPostViewModel : BaseViewModel
    {
        private DateTime _time;
        private int _topicId;
        

        public DiscussionPostViewModel(DiscussionPost post, int topicId)
        {
            this.Id = post.Id;
            this.Nick = post.Nick;
            this.Content = post.Content;
            this.MarkedUnread = post.MarkedUnread;
            this.Rating = post.Rating;
            this.NickImageUrl = post.NickImageUrl;
            this._time = post.DisplayTime;
            this._topicId = topicId;
            this.BrowserCommand = new Command(x =>
            {
                LinkHandler.Instance.OpenInBrowser(BrowserUrl);
            });
        }

        public int Id { get; private set; }
        public string Nick { get; private set; }
        public string Content { get; private set; }
        public bool MarkedUnread { get; private set; }
        public int Rating { get; private set; }
        public Uri NickImageUrl { get; private set; }
        public string DisplayTime { get { return _time.ToString(); } }
        public string BrowserUrl { get { return NyxLinksManager.GetDiscussionPostLink(_topicId, this.Id); } }
        public Command BrowserCommand { get; private set; }
    }
}
